package com.bdqn.zhao.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bdqn.zhao.dao.CmBillMapper;
import com.bdqn.zhao.pojo.CmBill;
import com.bdqn.zhao.service.CmBillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 账单信息表 服务实现类
 * </p>
 *
 * @author zhangsan
 * @since 2023-05-23
 */
@Service
public class CmBillServiceImpl extends ServiceImpl<CmBillMapper, CmBill> implements CmBillService {
   @Autowired
    private CmBillMapper cmBillMapper;
    @Override
    public Map<String, Object> SelAllJ(String billNumber, String billName) {
        QueryWrapper<CmBill> queryWrapper=new QueryWrapper<>();
        Map<String,Object> map=new HashMap<>();
        if (true) {
            if (billNumber != null) {
                queryWrapper.eq("bill_number", billNumber);
            }
            if (billName != null) {
                queryWrapper.eq("bill_name", billName);
            }
            List<CmBill> cmBills = cmBillMapper.selectList(queryWrapper);
            map.put("cmBillslist",cmBills);
        }else {
            List<CmBill> cmBills = cmBillMapper.selectList(null);
            map.put("cmBillslist",cmBills);
        }
        return map;
    }

    @Override
    public int DelJ(int id) {
        return cmBillMapper.deleteById(id);
    }
}
